package plugin.demo.runner.apt.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import plugin.demo.runner.apt.config.datasource.AptMysqlConfig;
import plugin.demo.runner.apt.config.load.YmlPropertiesLoadFactory;

import java.util.List;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2021/5/20 下午2:32
 * @UpdateDate:
 * @Description:
 */
@Component
@PropertySource(value = {"classpath:application-1.yml","classpath:application-2.yml"},
        encoding = "UTF-8",factory = YmlPropertiesLoadFactory.class)
@ConfigurationProperties(prefix = AptRunnerConfigurationProperties.APT_RUNNER_CONFIG_PREFIX)
public class AptRunnerConfigurationProperties {
    static final String APT_RUNNER_CONFIG_PREFIX = "apt.runner";
    //全局配置
    private Boolean enable;
    private List<String> paths;
    //系统配置
    private System system = new System();

    //模拟mysql配置, 嵌套的复杂类型(被定义成一个嵌套组)，且类文件不在本文件中定义.
    @NestedConfigurationProperty
    private AptMysqlConfig mysql = new AptMysqlConfig();


    public static class System{
        private String sysType;
        private Integer bit;

        public String getSysType() {
            return sysType;
        }

        public void setSysType(String sysType) {
            this.sysType = sysType;
        }

        public Integer getBit() {
            return bit;
        }

        public void setBit(Integer bit) {
            this.bit = bit;
        }
    }

    public System getSystem() {
        return this.system;
    }

    public AptMysqlConfig getMysql() {
        return this.mysql;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public List<String> getPaths() {
        return paths;
    }

    public void setPaths(List<String> paths) {
        this.paths = paths;
    }
}
